Skip to content

feat: add bounded structural evidence retrieval#9

Merged
sting8k merged 9 commits into
mainfrom
feat/public-evidence-retrieval
Jul 13, 2026
Merged

feat: add bounded structural evidence retrieval#9
sting8k merged 9 commits into
mainfrom
feat/public-evidence-retrieval

Conversation

@sting8k

@sting8k sting8k commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

public evidence retrieval
├─ CLI contract consistency
├─ context: bounded local structural links
└─ context + trace callees --detailed
   └─ unique direct-call target + positional arg/param mappings
  • Backports the public-safe CLI consistency fixes for intent errors and unresolved callee overflow wording.
  • Adds bounded same-function structural links to visible context call rows.
  • Adds conservative direct-call evidence for one exact same-file or explicitly related-file function target.
  • Adds positional argument-to-parameter mappings only when call arguments and signatures are structurally reliable.
  • Uses exact anchors, deterministic caps/omitted counts, and abstains on qualified, ambiguous, recursive, unresolved, or unreliable cases.

Public boundary

Not included:

  • rules, roles, predicates, hints, evaluators, or verdicts
  • private providers or premium harness files
  • runtime dataflow/type/dispatch claims
  • new commands or flags
  • distributed Guide duplication for evidence already visible in intent-command output
  • release, tag, or publish changes

Verification

  • cargo build --release --locked
  • cargo test --locked
  • cargo clippy --locked -- -D warnings
  • cargo fmt --check
  • cargo test --locked --test windows_paths
  • git diff --check
  • focused: 8 direct-call unit, 9 local-link unit, 21 flow-filter, and 11 detailed-callee tests
  • independent reviewer: PASS, no blockers or nits

Windows CI runs fmt, clippy, and the full locked test suite, including the new integration coverage.

sting8k added 5 commits July 13, 2026 14:48
Add conservative same/related-file direct-call evidence and positional argument mappings to context and detailed callees output. Abstain on qualified, ambiguous, recursive, or unreliable cases; keep call-derived local links within visible rows; and cover caps, filters, and false-positive regressions.
Document bounded local/direct-call evidence, regenerate checked-in CLI transcripts from the current binary, and keep output-visible routing details out of the distributed guide.
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds bounded structural evidence retrieval to srcwalk's context and callees --detailed outputs. The two new evidence modules (direct_call.rs, local_links.rs) are entirely additive, never replacing existing output, and each enforces explicit caps and deterministic omit counts to honour the bounded-output rule.

  • direct_call.rs: Resolves a call site's unique same-file or explicitly-related-file target, optionally emitting positional arg→param mappings. Conservatively abstracts on qualified calls, multiple matches, self-recursion, or unreliable signatures.
  • local_links.rs: Collects same-function structural bindings (FieldRead, AssignmentAlias, CallResult, ArgumentUse) via tree-sitter, then surfaces only chains that trace to a visible call site, filtered to avoid leaking evidence for call rows that were hidden by the 12-site cap.
  • CLI fixes: Default budget raised from 5,000 to 6,000 tokens (extracted to DEFAULT_OUTPUT_BUDGET), impact output now includes scope path and a broader-scope hint, and the unresolved-callee section is restructured to show call-site rows instead of a bare name list.

Confidence Score: 5/5

Safe to merge. All new code paths are additive, conservatively gated, and covered by focused integration tests that exercise the cap, filter, and abstention behaviour.

Both new evidence modules are purely additive with no changes to existing resolution or output contracts. Explicit budget caps, conservative abstention on ambiguity, and 49 new tests give high confidence the feature behaves as specified. The CLI fixes are straightforward and also covered by updated integration tests.

No files require special attention. The most complex new files — src/evidence/direct_call.rs and src/evidence/local_links.rs — have dedicated test modules and are cross-validated by the flow-filter and callees-detailed integration tests.

Important Files Changed

Filename Overview
src/evidence/direct_call.rs New module: resolves unique direct-call targets with positional arg/param mappings. Well-bounded with explicit caps (32 edges, 16 unknowns, 20 related files). Conservative abstention on qualified calls, ambiguity, self-recursion, and unreliable signatures.
src/evidence/local_links.rs New module: tree-sitter structural link collection within a function body. Budget cap (256 links) and conservative dedup/chain-uniqueness checks prevent unbounded output and false chains.
src/commands/flow.rs Adds append_local_structural_links and append_direct_call_evidence to context output. Both correctly limit to the 12-site visible neighbourhood; visible_sites is shared across both sections for consistent filtering.
src/commands/callees.rs Adds direct-call evidence to --detailed output and rewrites unresolved callee section to show per-site rows with a LIMIT of 12, preserving names with no rendered row in a separate line.
src/cli_run.rs Extracts budget resolution to a pure resolve_output_budget function and raises the default from 5000 to 6000. A unit test pins the constant and verifies all four flag combinations.
src/map.rs Adds early-return path when visible_files is empty, emitting a diagnostic message and a next-action hint instead of falling through to compute_relations with an empty set.
tests/flow_filter.rs Nine new integration tests covering local-structural-link display, cap enforcement, filter scoping, hidden-call exclusion, and direct-call evidence isolation. Tests are specific and deterministic.
tests/callees_detailed.rs Three new unresolved-evidence tests and one direct-call mapping test; covers row-cap spillover, nested unresolved names, and ambiguity abstention.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant CLI
    participant flow.rs as flow.rs (context)
    participant callees.rs
    participant local_links.rs
    participant direct_call.rs

    CLI->>flow.rs: srcwalk context target
    flow.rs->>flow.rs: filter_call_sites to visible_sites
    flow.rs->>local_links.rs: collect_local_links_for_function_spans
    local_links.rs-->>flow.rs: LocalLinkGraph (budget flag)
    flow.rs->>flow.rs: append_local_structural_links
    flow.rs->>direct_call.rs: build_direct_call_evidence_index(visible_sites)
    direct_call.rs->>direct_call.rs: collect same-file + related-file targets
    direct_call.rs-->>flow.rs: DirectCallEvidenceIndex
    flow.rs->>flow.rs: append_direct_call_evidence

    CLI->>callees.rs: srcwalk trace callees fn --detailed
    callees.rs->>direct_call.rs: build_direct_call_evidence_index(filtered_sites)
    direct_call.rs-->>callees.rs: DirectCallEvidenceIndex
    callees.rs->>callees.rs: edge_for_site / unknown_for_site inline evidence
    callees.rs->>callees.rs: append_unresolved_call_site_evidence
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant CLI
    participant flow.rs as flow.rs (context)
    participant callees.rs
    participant local_links.rs
    participant direct_call.rs

    CLI->>flow.rs: srcwalk context target
    flow.rs->>flow.rs: filter_call_sites to visible_sites
    flow.rs->>local_links.rs: collect_local_links_for_function_spans
    local_links.rs-->>flow.rs: LocalLinkGraph (budget flag)
    flow.rs->>flow.rs: append_local_structural_links
    flow.rs->>direct_call.rs: build_direct_call_evidence_index(visible_sites)
    direct_call.rs->>direct_call.rs: collect same-file + related-file targets
    direct_call.rs-->>flow.rs: DirectCallEvidenceIndex
    flow.rs->>flow.rs: append_direct_call_evidence

    CLI->>callees.rs: srcwalk trace callees fn --detailed
    callees.rs->>direct_call.rs: build_direct_call_evidence_index(filtered_sites)
    direct_call.rs-->>callees.rs: DirectCallEvidenceIndex
    callees.rs->>callees.rs: edge_for_site / unknown_for_site inline evidence
    callees.rs->>callees.rs: append_unresolved_call_site_evidence
Loading

Reviews (2): Last reviewed commit: "chore: prepare v1.1.0 release" | Re-trigger Greptile

Comment thread src/evidence/direct_call.rs
@sting8k
sting8k merged commit 47bbbbc into main Jul 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant